layui.config({
    base: '/Plugin/',
}).extend({ //设定模块别名
    common: 'common',
    jqx: 'jqx'
}).use(['element', 'form', 'laypage', 'jquery', 'laytpl', 'flow', 'util', "layer", "common", "jqx", "table"], function () {
    var element = layui.element,
        $ = layui.jquery,
        form = layui.form,
        laypage = layui.laypage,
        laytpl = layui.laytpl,
        util = layui.util,
        layer = layui.layer,
        table = layui.table,
        common = layui.common,
        jqx = layui.jqx,
        flow = layui.flow;

    var jhy = layui.data("jhy"),
        URL = window.location.href,
        device = layui.device();




    //加载网站信息
    common.site();
    //首页文章加载
    if ($("body.index").html() != undefined) {
        //start 添加访问记录 
        $.post("/Ashx/admin.ashx", { functionname: "jhy_browsing_add", b_url: (jhy.user_id == undefined ? "游客：" : "系统用户：") + "浏览【首页】[系统:" + device.os + ",IE:" + (device.ie == true ? "是" : "否") + ",微信：" + (device.weixin == true ? "是" : "否") + ",安卓：" + (device.android == true ? "是" : "否") + ",苹果：" + (device.ios == true ? "是" : "否") + "]" });
        //end 添加访问记录
        flow.load({
            elem: '#flow',
            mb: 100,
            done: function (page, next) {
                var url = decodeURIComponent(URL);
                var art_title = jqx.getUrlParam("art_title");
                art_title = null ? art_title = "" : art_title;
                var lis = [];
                $.ajax({
                    type: "post",
                    url: "/Ashx/article.ashx",
                    data: { functionname: "jhy_index_flow", art_title: art_title, laypage: page },
                    dataType: 'json',
                    success: function (msg) {
                        layui.each(msg.data, function (index, item) {
                            var str =
                                "<div class=\"item\">\
                                <div class=\"item-box  layer-photos-demo1 layer-photos-demo\">\
                                <h3><a href=\"details.html?art_id="+ item.art_id + "\">" + item.art_title + "</a></h3>\
                                <h5>发布于：<span>"+ util.timeAgo(item.art_datetime, true) + "</span></h5>\
                                "+ unescape(item.art_intro) + "\
                                </div >\
                                </div >";

                            lis.push(str);
                        });
                        next(lis.join(''), page < msg.count);
                    }
                });

            }
        });
    }

    //start显示文章内容
    if ($("body.details").html() != undefined) {
        var art_id = jqx.getUrlParam("art_id");
        if (art_id == null) {
            window.location.href = "/index.html";
        } else {
            var w = $(".item-box").width();
            $.ajax({
                type: "post",
                url: "/Ashx/article.ashx",
                data: { functionname: "jhy_index_details", art_id: art_id },
                dataType: 'json',
                success: function (msg) {
                    //start 添加访问记录 
                    $.post("/Ashx/admin.ashx", { functionname: "jhy_browsing_add", b_url: (jhy.user_id == undefined ? "游客：" : "系统用户：") + "浏览文章【" + msg[0].art_title + "】[系统:" + device.os + ",IE:" + (device.ie == true ? "是" : "否") + ",微信：" + (device.weixin == true ? "是" : "否") + ",安卓：" + (device.android == true ? "是" : "否") + ",苹果：" + (device.ios == true ? "是" : "否") + "]" });
                    //end 添加访问记录
                    $("title").html(msg[0].art_title);
                    $(".item-box").html("<h3><a href=\"javascript:;\">" + msg[0].art_title + "</a></h3>\
                        <h5>发布于：<span>"+ util.timeAgo(msg[0].art_datetime, true) + "</span></h5>\
                        "+ unescape(msg[0].art_content) + "");

                    if ($(".item-box").find("img").length > 0) {
                        $(".item-box").find("img").each(function (a, b) {
                            if (b.width == 0) {
                                setTimeout(function () {
                                    if (b.width > w) {
                                        b.width = w;
                                    }
                                }, 1000);
                            } else {
                                if (b.width > w) {
                                    b.width = w;
                                }
                            }

                        });
                    }

                }
            });
        }
    }
    //end显示文章内容







    // start 导航显示隐藏
    $("#mobile-nav").on('click', function () {
        $("#pop-nav").toggle();
    });

    // end 导航显示隐藏


    // start点赞图标变身
    $('#LAY-msg-box').on('click', '.info-img', function () {
        $(this).addClass('layblog-this');
    })
    // end点赞图标变身


    // start  图片遮罩
    var layerphotos = document.getElementsByClassName('layer-photos-demo');
    for (var i = 1; i <= layerphotos.length; i++) {
        layer.photos({
            photos: ".layer-photos-demo" + i + "",
            anim: 0
        });
    }
    // end 图片遮罩






    //start显示关于

    if (URL.indexOf("about.html") != -1) {
        $.ajax({
            type: "post",
            url: "/Ashx/admin.ashx",
            data: { functionname: "jhy_site_query" },
            dataType: 'json',
            success: function (msg) {
                $(".item-box").append(unescape(msg[0].site_about));
            }
        });

    }
    //end显示关于





});  
